package com.stn.zjx.givingtreasure.fragment.main;

import android.graphics.Paint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.widget.NestedScrollView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.Gson;
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
import com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.makeramen.roundedimageview.RoundedImageView;
import com.stn.zjx.givingtreasure.R;
import com.stn.zjx.givingtreasure.activity.UserLoginActivity;
import com.stn.zjx.givingtreasure.activity.askhelp.AskLingHelpMapActivity;
import com.stn.zjx.givingtreasure.activity.intelligence.IntelliGenceRobotActivity;
import com.stn.zjx.givingtreasure.activity.msg.MsgTypeListActivity;
import com.stn.zjx.givingtreasure.activity.scan.StoreScanActivity;
import com.stn.zjx.givingtreasure.activity.search.StoreShopSearchActivity;
import com.stn.zjx.givingtreasure.activity.subldle.SubIdleActivity;
import com.stn.zjx.givingtreasure.activity.web.GenericWebActivity;
import com.stn.zjx.givingtreasure.base.BaseMainFragment;
import com.stn.zjx.givingtreasure.demo.IndexZeroStore;
import com.stn.zjx.givingtreasure.domain.UserProfileDomain;
import com.stn.zjx.givingtreasure.event.NetWorkEvent;
import com.stn.zjx.givingtreasure.net.BaseApi;
import com.stn.zjx.givingtreasure.net.impl.MsgNetImpl;
import com.stn.zjx.givingtreasure.net.impl.UserNetImpl;
import com.stn.zjx.givingtreasure.service.UserService;
import com.stn.zjx.givingtreasure.table.User;
import com.stn.zjx.givingtreasure.utils.StatusBarUtil;
import com.stn.zjx.givingtreasure.utils.ToolsUtils;
import com.stn.zjx.givingtreasure.widget.GradientTextView;
import com.vondear.rxtools.RxActivityTool;
import com.vondear.rxtools.view.RxTextViewVerticalMore;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bingoogolapple.bgabanner.BGABanner;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

@SuppressWarnings("all")
public class MainIndexFragment extends BaseMainFragment {
    public View rootView;
    @BindView(R.id.banner_content)
    BGABanner bannerContent;
    @BindView(R.id.pager_left)
    LinearLayout pagerLeft;
    @BindView(R.id.new_pager_more_bt)
    LinearLayout newPagerMoreBt;
    @BindView(R.id.new_pager_tv)
    RxTextViewVerticalMore newPagerTv;
    @BindView(R.id.zero_update_time_tv)
    TextView zeroUpdateTimeTv;
    @BindView(R.id.zero_store_content)
    LinearLayout zeroStoreContent;
    @BindView(R.id.hot_store_title_tv)
    GradientTextView hotStoreTitleTv;
    @BindView(R.id.main_index_hot_store_iv)
    ImageView mainIndexHotStoreIv;
    @BindView(R.id.brand_store_title_tv)
    GradientTextView brandStoreTitleTv;
    @BindView(R.id.main_index_brand_store_iv)
    ImageView mainIndexBrandStoreIv;
    @BindView(R.id.multiple_delivery_title_tv)
    GradientTextView multipleDeliveryTitleTv;
    @BindView(R.id.give_iv1)
    ImageView giveIv1;
    @BindView(R.id.give_iv2)
    ImageView giveIv2;
    @BindView(R.id.give_iv7)
    ImageView giveIv7;
    @BindView(R.id.give_iv8)
    ImageView giveIv8;
    @BindView(R.id.give_iv3)
    ImageView giveIv3;
    @BindView(R.id.give_iv4)
    ImageView giveIv4;
    @BindView(R.id.give_iv5)
    ImageView giveIv5;
    @BindView(R.id.give_iv6)
    ImageView giveIv6;
    @BindView(R.id.give_iv9)
    ImageView giveIv9;
    @BindView(R.id.give_iv10)
    ImageView giveIv10;
    @BindView(R.id.give_iv11)
    ImageView giveIv11;
    @BindView(R.id.give_iv12)
    ImageView giveIv12;
    @BindView(R.id.nestedScrollView)
    NestedScrollView nestedScrollView;
    @BindView(R.id.twinkling_refresh)
    TwinklingRefreshLayout twinklingRefresh;
    @BindView(R.id.head_top_nv_bg)
    RelativeLayout headTopNvBg;
    @BindView(R.id.left_scan_bg)
    RelativeLayout leftScanBg;
    @BindView(R.id.head_scan_iv)
    ImageView headScanIv;
    @BindView(R.id.head_scan_tv)
    TextView headScanTv;
    @BindView(R.id.head_scan_bt)
    RelativeLayout headScanBt;
    @BindView(R.id.right_msg_bg)
    RelativeLayout rightMsgBg;
    @BindView(R.id.head_msg_iv)
    ImageView headMsgIv;
    @BindView(R.id.head_msg_tv)
    TextView headMsgTv;
    @BindView(R.id.head_msg_ll)
    LinearLayout headMsgLl;
    @BindView(R.id.msg_tip_dot)
    View msgTipDot;
    @BindView(R.id.head_msg_bt)
    RelativeLayout headMsgBt;
    @BindView(R.id.head_search_iv)
    ImageView headSearchIv;
    @BindView(R.id.head_search_tv)
    TextView headSearchTv;
    @BindView(R.id.robot_open_bt)
    RelativeLayout robotOpenBt;
    @BindView(R.id.head_search_bg)
    RelativeLayout headSearchBg;
    @BindView(R.id.head_top_bg)
    RelativeLayout headTopBg;
    @BindView(R.id.go_login)
    Button goLogin;
    @BindView(R.id.go_login_tip)
    RelativeLayout goLoginTip;



    @Override
    public void networkStatus(NetWorkEvent netWorkEvent) {

    }

    @Override
    public View initView(LayoutInflater inflater, ViewGroup container) {
        if (rootView == null) {
            rootView = View.inflate(activity, R.layout.fragment_main_index, null);
            ButterKnife.bind(this, rootView);
            initView();


        }
        return rootView;
    }

    public void initView() {
        ProgressLayout headerView = new ProgressLayout(activity);
        headerView.setColorSchemeResources(R.color.colorAccent);
        nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView nestedScrollView, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {

                double y = ToolsUtils.dip2px(activity, 100);
                Log.d("**********************", "scrollY:" + scrollY + "y:" + y);
                if (scrollY <= 0) {
                    Log.d("**********************", "scrollY<=0");
                    headTopNvBg.setAlpha(0);
                    leftScanBg.setVisibility(View.VISIBLE);
                    rightMsgBg.setVisibility(View.VISIBLE);
                    headScanIv.setImageResource(R.mipmap.scan_white);
                    headMsgIv.setImageResource(R.mipmap.white_msg);
                    headScanTv.setTextColor(ActivityCompat.getColor(activity, R.color.white));
                    headMsgTv.setTextColor(ActivityCompat.getColor(activity, R.color.white));
                    headSearchBg.setBackgroundResource(R.drawable.shape_round_white_40dp);
                    headSearchTv.setTextColor(ActivityCompat.getColor(activity, R.color.gray1));
                    headSearchIv.setImageResource(R.mipmap.gray_search1);
                    StatusBarUtil.setImmersiveStatusBar(activity, false);
                } else if (scrollY <= y) {
                    DecimalFormat decimalFormat = new DecimalFormat("0.00");
                    double result = scrollY / y;
                    headTopNvBg.setAlpha((float) result);
                    leftScanBg.setVisibility(View.VISIBLE);
                    rightMsgBg.setVisibility(View.VISIBLE);
                    headScanIv.setImageResource(R.mipmap.scan_white);
                    headMsgIv.setImageResource(R.mipmap.white_msg);
                    headScanTv.setTextColor(ActivityCompat.getColor(activity, R.color.white));
                    headMsgTv.setTextColor(ActivityCompat.getColor(activity, R.color.white));
                    headSearchBg.setBackgroundResource(R.drawable.shape_round_white_40dp);
                    headSearchTv.setTextColor(ActivityCompat.getColor(activity, R.color.gray1));
                    headSearchIv.setImageResource(R.mipmap.gray_search1);
                    StatusBarUtil.setImmersiveStatusBar(activity, false);
                    Log.d("**********************", "resullt" + decimalFormat.format(result));
                } else {
                    Log.d("**********************", "scrollY");
                    headTopNvBg.setAlpha(1);
                    leftScanBg.setVisibility(View.GONE);
                    rightMsgBg.setVisibility(View.GONE);
                    headScanIv.setImageResource(R.mipmap.scan_black);
                    headMsgIv.setImageResource(R.mipmap.black_msg);
                    headScanTv.setTextColor(ActivityCompat.getColor(activity, R.color.default_black));
                    headMsgTv.setTextColor(ActivityCompat.getColor(activity, R.color.default_black));
                    headSearchBg.setBackgroundResource(R.drawable.shape_default_gray_40dp);
                    headSearchTv.setTextColor(ActivityCompat.getColor(activity, R.color.white));
                    headSearchIv.setImageResource(R.mipmap.white_search1);
                    StatusBarUtil.setImmersiveStatusBar(activity, true);
                }
            }
        });
        twinklingRefresh.setHeaderView(headerView);

        twinklingRefresh.setOnRefreshListener(new RefreshListenerAdapter() {
            @Override
            public void onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction) {
                super.onPullingUp(refreshLayout, fraction);

            }

            @Override
            public void onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction) {
                super.onPullingDown(refreshLayout, fraction);
                headTopBg.setVisibility(View.GONE);
                headTopNvBg.setAlpha(0);
            }

            @Override
            public void onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction) {
                super.onPullDownReleasing(refreshLayout, fraction);
                headTopBg.setVisibility(View.VISIBLE);
                headTopNvBg.setAlpha(0);
            }

            @Override
            public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        activity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                twinklingRefresh.finishRefreshing();
                            }
                        });
                    }
                }).start();
            }

            @Override
            public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {

            }
        });
        int[] hotStoreTitleColors = new int[2];
        hotStoreTitleColors[0] = ActivityCompat.getColor(activity, R.color.gradient_color1);
        hotStoreTitleColors[1] = ActivityCompat.getColor(activity, R.color.gradient_color2);
        hotStoreTitleTv.setmColorList(hotStoreTitleColors);

        int[] brandTitleColors = new int[2];
        brandTitleColors[0] = ActivityCompat.getColor(activity, R.color.gradient_color3);
        brandTitleColors[1] = ActivityCompat.getColor(activity, R.color.gradient_color4);
        brandStoreTitleTv.setmColorList(brandTitleColors);

        int[] multipleTitleColors = new int[2];
        multipleTitleColors[0] = ActivityCompat.getColor(activity, R.color.gradient_color7);
        multipleTitleColors[1] = ActivityCompat.getColor(activity, R.color.gradient_color8);
        multipleDeliveryTitleTv.setmColorList(multipleTitleColors);

    }

    @Override
    public void initData() {
        initBanner();
        initPager();
        updateTime();
        giveMulti();
    }


    public void initDefault() {
        goLoginTip.setVisibility(View.VISIBLE);
        msgTipDot.setVisibility(View.GONE);
    }

    public void initLocationUser() {
        User userOnline = UserService.getInstance(activity).getOnlineLoginUser();
        if (userOnline == null) {
            return;
        }
        goLoginTip.setVisibility(View.GONE);
        MsgNetImpl
                .query_get_no_read_all_msg(userOnline.getToken(), userOnline.getUserId() + "_query_get_no_read_all_msg",
                        new StringCallback() {
                            @Override
                            public void onSuccess(Response<String> response) {
                                if (response.isSuccessful() && !activity.isFinishing()) {
                                    query_get_no_read_all_msg(response.body());
                                }

                            }

                            @Override
                            public void onCacheSuccess(Response<String> response) {
                                super.onCacheSuccess(response);
                                if (response.isSuccessful() && !activity.isFinishing()) {
                                    query_get_no_read_all_msg(response.body());
                                }
                            }
                        });
    }

    //获取未读消息
    public void query_get_no_read_all_msg(String data) {
        if (data == null || data.length() == 0) {
            return;
        }
        try {
            JSONObject result = new JSONObject(data);
            switch (result.getInt(BaseApi.KEY_STATUS)) {
                case BaseApi.REQUEST_SUCCESS_CODE:
                    int msg_count = result.getInt("data");
                    if (msg_count == 0) {
                        msgTipDot.setVisibility(View.GONE);
                    } else {
                        msgTipDot.setVisibility(View.VISIBLE);
                    }
                    break;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    //初始化获取用户信息
    public void initUser() {
        if (UserService.getInstance(activity).getOnlineLoginUser() == null) {
            initDefault();
            return;
        }
        User userOnline = UserService.getInstance(activity).getOnlineLoginUser();
        UserNetImpl.user_getuserprofile_bytoken(userOnline.getToken(), userOnline.getUserId() + "user_getuserprofile_bytoken",
                new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (response.isSuccessful() && !activity.isFinishing()) {
                            user_getuserprofile_bytoken(response.body());
                        }
                    }

                    @Override
                    public void onCacheSuccess(Response<String> response) {
                        super.onCacheSuccess(response);
                        if (response.isSuccessful() && !activity.isFinishing()) {
                            user_getuserprofile_bytoken(response.body());
                        }
                    }
                });


    }

    @Override
    public void onStart() {
        super.onStart();
        initUser();
    }

    //成功登录
    private void loginSuccess(UserProfileDomain domain) {
        boolean isLogin = UserService.getInstance(activity)
                .login(domain.getData());
        if (!isLogin) {
            boolean isExitLogin = UserService.getInstance(activity)
                    .exitLogin();
            if (isExitLogin) {
                initDefault();
            }
        }
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            if (rootView != null) {
                initUser();
            }
        }
    }

    //处理，通过token获取用户个人资料后的操作
    public void user_getuserprofile_bytoken(String result) {
        if (result == null || result.length() == 0) {
            return;
        }
        Gson gson = new Gson();
        UserProfileDomain domain = gson.fromJson(result.trim(), UserProfileDomain.class);
        switch (domain.getStatus()) {
            case BaseApi.REQUEST_SUCCESS_CODE:
                loginSuccess(domain);
                initLocationUser();
                break;
            case BaseApi.REQUEST_LOGINEXIT_ERROR_CODE:
                activity.showToast(domain.getMessage());
                boolean isExitLogin = UserService.getInstance(activity)
                        .exitLogin();
                if (isExitLogin) {
                    initDefault();
                }
                break;
            case BaseApi.REQUEST_TOKEN_ERROR_CODE:
                boolean isExit = UserService.getInstance(activity)
                        .exitLogin();
                if (isExit) {
                    initDefault();
                }
                break;
        }
    }


    @OnClick({R.id.go_login, R.id.go_login_tip,
            R.id.head_scan_bt, R.id.head_msg_bt,
            R.id.head_search_bg,
            R.id.robot_open_bt,
            R.id.go_ask_help,
            R.id.ldle_bt
    })
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //登录按钮
            case R.id.go_login:
                RxActivityTool.skipActivity(activity, UserLoginActivity.class);
                break;
            case R.id.go_login_tip:
                RxActivityTool.skipActivity(activity, UserLoginActivity.class);
                break;
            //商品扫码
            case R.id.head_scan_bt:
                RxActivityTool.skipActivity(activity, StoreScanActivity.class);
                break;

            case R.id.head_msg_bt:
                if (UserService.getInstance(activity).getOnlineLoginUser() == null) {
                    RxActivityTool.skipActivity(activity, UserLoginActivity.class);
                    return;
                }
                RxActivityTool.skipActivity(activity, MsgTypeListActivity.class);
                break;
            case R.id.head_search_bg:
                RxActivityTool.skipActivity(activity, StoreShopSearchActivity.class);
                break;
            case R.id.robot_open_bt:
                RxActivityTool.skipActivity(activity, IntelliGenceRobotActivity.class);
                break;
            case R.id.go_ask_help:
                RxActivityTool.skipActivity(activity,AskLingHelpMapActivity.class);
                break;
            case R.id.ldle_bt:
                RxActivityTool.skipActivity(activity,SubIdleActivity.class);
                break;
        }
    }


    public void initBanner() {

        List<String> datas = new ArrayList<>();
        datas.add("https://img.alicdn.com/tfs/TB1pBhhrhTpK1RjSZFMXXbG_VXa-520-280.jpg_q90");
        datas.add("https://img.alicdn.com/simba/img/TB1E9JSo6TpK1RjSZKPSuu3UpXa.jpg");
        datas.add("https://img.alicdn.com/tps/i4/TB1FzFnrrPpK1RjSZFFSuu5PpXa.jpg_q90");
        datas.add("https://m.360buyimg.com/babel/jfs/t28804/269/457060883/99677/864568cf/5bf3e108N678f3db4.jpg");
        if (datas == null || datas.size() == 0) {
            return;
        }
        bannerContent.setAdapter(new BGABanner.Adapter() {
            @Override
            public void fillBannerItem(BGABanner banner, View itemView, @Nullable Object model, int position) {
                System.out.println("*********************model:" + model);
            }
        });
        List<View> viewList = new ArrayList<>();
        View view = null;
        for (int i = 0; i < datas.size(); i++) {
            String data = datas.get(i);
            view = View.inflate(activity, R.layout.item_banner_layout1, null);
            RoundedImageView iv = view.findViewById(R.id.iv);
            Glide.with(MainIndexFragment.this)
                    .load(data)
                    .apply(new RequestOptions().fitCenter())
                    .transition(DrawableTransitionOptions.withCrossFade())
                    .into(iv);
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Bundle bundle = new Bundle();
                    bundle.putString("url", "https://detail.tmall.com/item.htm?id=524773730320&spm=a310p.7395725.1998038907.1.63f25564WzlIBu");
                    RxActivityTool.skipActivity(activity, GenericWebActivity.class, bundle);
                }
            });

            viewList.add(view);
        }
        bannerContent.setData(viewList, datas, null);

    }


    //垂直新闻
    public void initPager() {


        List<View> viewList = new ArrayList<>();
        View pagerView = null;

        for (int i = 0; i < 10; i++) {
            pagerView = View.inflate(activity, R.layout.item_news_pager_switch, null);
            TextView pager_title = pagerView.findViewById(R.id.pager_title);
            TextView pager_content = pagerView.findViewById(R.id.pager_content);
            String data = "数据：" + i;
            pagerView.setTag(data);
            viewList.add(pagerView);
        }
        newPagerTv.setViews(viewList);
        newPagerTv.setOnItemClickListener(new RxTextViewVerticalMore.OnItemClickListener() {
            @Override
            public void onItemClick(int position, View view) {
                activity.showToast(view.getTag().toString());
            }
        });
    }


    //倒计时，热卖，送宝推荐，大减价，品牌
    public void updateTime() {
        Disposable disposable = null;
        Date date = new Date();
        long nextTime = date.getTime() + 180000;

        disposable = Observable.create(new ObservableOnSubscribe<Long>() {
            @Override
            public void subscribe(ObservableEmitter<Long> emitter) throws Exception {
                while (nextTime > System.currentTimeMillis()) {
                    emitter.onNext(nextTime - System.currentTimeMillis());
                    Thread.sleep(1000);
                }
                emitter.onComplete();
            }
        }).subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnComplete(new Action() {
                    @Override
                    public void run() throws Exception {
                        updateTime();
                    }
                })
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        zeroUpdateTimeTv.setText(ToolsUtils.formatTime(aLong));

                    }

                });

        List<IndexZeroStore> stores = new ArrayList<>();
        IndexZeroStore zs = new IndexZeroStore();
        zs.url = "https://img.alicdn.com/imgextra/i4/129/TB2wR1mf6oIL1JjSZFyXXbFBpXa_!!129-2-luban.png_240x240q90.jpg";
        zs.origin_price = "111.00";
        zs.now_price = "0.00";

        IndexZeroStore zs1 = new IndexZeroStore();
        zs1.url = "https://img.alicdn.com/imgextra/i2/165/TB2e0x7X138SeJjSZFPXXc_vFXa_!!165-2-luban.png_240x240q90.jpg";
        zs1.origin_price = "59.00";
        zs1.now_price = "0.00";
        IndexZeroStore zs2 = new IndexZeroStore();
        zs2.url = "https://img.alicdn.com/imgextra/i2/190/TB2oU0EXaagSKJjy0FaXXb0dpXa_!!190-2-luban.png_240x240q90.jpg";
        zs2.origin_price = "152.00";
        zs2.now_price = "0.00";
        stores.add(zs);
        stores.add(zs1);
        stores.add(zs2);

        zeroStoreContent.removeAllViews();
        View view = null;
        for (int i = 0; i < stores.size(); i++) {
            IndexZeroStore izs = stores.get(i);
            view = View.inflate(activity, R.layout.item_main_index_zero_store, null);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            lp.weight = 1;
            view.setLayoutParams(lp);
            ImageView iv = view.findViewById(R.id.iv);
            TextView now_price_tv = view.findViewById(R.id.now_price_tv);
            TextView origin_price_tv = view.findViewById(R.id.origin_price_tv);
            origin_price_tv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);  // 设置中划线并加清晰
            Glide.with(MainIndexFragment.this)
                    .load(izs.url)
                    .apply(new RequestOptions().fitCenter())
                    .transition(DrawableTransitionOptions.withCrossFade())

                    .into(iv);
            now_price_tv.setText("¥" + izs.now_price);
            origin_price_tv.setText("¥" + izs.origin_price);
            zeroStoreContent.addView(view);
        }

        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i3/102/TB28yjTdwoQMeJjy0FpXXcTxpXa_!!102-2-luban.png_360x360q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(mainIndexHotStoreIv);


        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i4/37/TB2vUd6cRxRMKJjy0FdXXaifFXa_!!37-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(mainIndexBrandStoreIv);

    }
    //多送

    public void giveMulti() {
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i1/71/TB2ABoCfBcHL1JjSZJiXXcKcpXa_!!71-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv1);
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i3/81/TB282btfoEIL1JjSZFFXXc5kVXa_!!81-2-luban.png_200x200q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv2);
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i2/172/TB2zzZQXHH8F1Jjy1zbXXaVNVXa_!!172-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv3);
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i4/164/TB2ObbiX7z_F1JjSZFkXXcCaXXa_!!164-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv4);
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i4/112/TB2H4livB8lpuFjSspaXXXJKpXa_!!112-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv5);


        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/tfs/TB1EsuxhkvoK1RjSZFNXXcxMVXa-186-186.png_200x200q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv6);

        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i4/159/TB2aszIdwMPMeJjy1XdXXasrXXa_!!159-2-luban.png_200x200q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv7);


        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/tfs/TB1B_UBf3vD8KJjy0FlXXagBFXa-800-800.jpg_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv8);


        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/bao/uploaded/i1/bao/upload/TB1WwS9w8jTBKNjSZFDwu2VgVXa.png_288x480Q75s0.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv9);
        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/bao/uploaded/i4/106852162/O1CN011RqEkdv2wOB2f5W_!!106852162.jpg_320x5000Q50s50.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())

                .into(giveIv10);

        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/bao/uploaded/i4/1601196901/TB2iQzbFQyWBuNjy0FpXXassXXa_!!1601196901.jpg_320x5000Q50s50.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(giveIv11);

        Glide.with(MainIndexFragment.this)
                .load("https://img.alicdn.com/imgextra/i1/38/TB2fX3mvhXlpuFjSsphXXbJOXXa_!!38-2-luban.png_240x240q90.jpg")
                .apply(new RequestOptions().fitCenter())
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(giveIv12);


    }

}
